<template>
  <div>
    <m-header :title="iNowTitle"></m-header>
    <div class="customer">
      <div class="total_cash">
        <div class="cashMoney">
          <p class="cash_font_one">&nbsp;累计提现金额</p>
          <p class="cash_font_two">￥{{moneyObj.totalMoney|formatMoney}}</p>
        </div>
      </div>
      <div class="customer_list">
        <div class="tab_header">
          <table>
            <thead>
            <th class="thOne">提现时间</th>
            <th>提现金额</th>
            <th>提现状态</th>
            </thead>
            <tbody>
            <td v-if="tabList.length == 0" class="tab_nodata" colspan=4  >暂无数据</td>
            <tr v-if="tabList.length" v-for="item in tabList">
              <td class="td_indent" v-html="item.withdrawDate"></td>
              <td v-html="item.withdrawMoney"></td>
              <td v-if="item.withdrawStatus == '0'">待审核</td>
              <td v-if="item.withdrawStatus == '1'">成功</td>
              <td v-if="item.withdrawStatus == '2'">审核不通过</td>
            </tr>
            </tbody>
          </table>
        </div>
        <Page :total="listData.totalCount" show-total :page-size="listData.pageSize" size="small"
              v-if="listData.totalCount > 0"
              @on-change="handleChange"></Page>
      </div>
    </div>
    <Copyright></Copyright>
  </div>
</template>

<script type="text/ecmascript-6">
  import MHeader from 'base/m-header/m-header'
  import {ERR_OK} from 'config/config'
  import {Toast} from 'mint-ui'
  import 'mint-ui/lib/toast/style.css';
  import Copyright from 'base/copyright/copyright'
  import {Page} from 'iview'


  export default {
    data() {
      return {
        iNowTitle: '我的提现记录',
        moneyObj: {
          totalMoney: '00.00'
        },
        tabList: [],
        listData: {
          pageNum: 1,
          pageSize: 20,
          totalCount: 0,
        }
      }
    },
    computed:{
      toNumb:function(){
        return Number(this.moneyObj.totalMoney).toFixed(2)
      }
    },
    created() {
      this.getStatistics();
      this.getCustomers();
    },
    methods: {
      getStatistics() {
        this.$http({
          method: 'post',
          url: '/mobile/api/v1.0/withdraw/getWithdrawCashRecord',
          data: {
            pageNum: this.listData.pageNum,
            pageSize: this.listData.pageSize
          }
        }).then((res) => {
          console.log(res)
          if (res.data.code == ERR_OK) {
            console.log(res.data.data.currentData)
            this.tabList = res.data.data.currentData;
            this.listData.totalCount = res.data.data.totalCount;
          } else {
            Toast('请求失败，请刷新')
          }
        }).catch((err) => {
          console.log(err)
        })
      },
      handleChange(index) {
        this.listData.pageNum = index;
        this.getStatistics();
      },
      getCustomers() {
        this.$http({
          method: 'post',
          url: '/mobile/api/v1.0/withdraw/getWithdrawCashTotalMoney'
        }).then((res) => {
          if (res.data.code == ERR_OK) {
//            this.moneyObj = res.data.data;
          } else {
            Toast('请求失败，请刷新')
          }
        }).catch((err) => {
          console.log(err)
        })
      }
    },
    components: {
      MHeader,
      Copyright,
      Page
    }
  }
</script>

<style lang="less" rel="stylesheet/less">
  .ivu-page.mini .ivu-page-total {
    display: block;
  }

  .ivu-page.mini .ivu-page-next, .ivu-page.mini .ivu-page-prev {
    min-width: 12px !important;
  }
</style>
